package com.Generics;

public class ScoreMain {
    public static void main(String[] args) throws Exception {
        Score score1 = new Score("数学", "666", 80.0);
        Score score2 = new Score("语文", "667", "优秀");
        Score score3 = new Score("化学", "668", 70);

        System.out.println(score1.name);
        System.out.println(score1.id);
        System.out.println(score1.score);

        //强制类型转换
        String str = (String) score2.score;
        System.out.println(str);

        Double d = (Double) score1.score;
        System.out.println(d);

        //对Object类型可以强制类型转换，但引用多了，或中间逻辑多了，就忘了是类型什么，才能确定要转换为什么类型。转换错误会报错
        //这种弊端是必须先知道原始数据是什么类型，才能强制类型转换。

        Double d1 = (Double) score3.score;  //会报错

    }
}
